import echarts from "echarts";
function opt(value) {
    const option = {
        title: [
            {
                text: '下载量',
                x: 'center',
                bottom: '15%',
                textStyle: {
                    fontSize: 16,
                    color: '#585b5c',
                },
                borderWidth:1,
                borderColor:'#4a5571',
                padding:[8,22,5,22],
                borderRadius:15,
                backgroundColor:'rgba(0,0,0,.6)'
            },
            {
                text: `${value}/h`,
                x: 'center',
                top: '46%',
                textStyle: {
                    fontSize: 20,
                    color: '#fff',
                    fontWeight:'300'
                },
            }
        ],
        tooltip: {
            show:false,
            trigger: 'item',
            formatter: '{a} <br/>{b}: {c} ({d}%)',
            textStyle: {
                fontSize: 10
            },
        },
        color: ['#45494b', '#32b16c'],
        legend: {
            show: false,
            orient: 'horizontal',
            left: 'center',
            bottom: 0,
            data: ['类别一', '类别二', '类别三', '类别四'],
            textStyle: {
                color: '#fff'
            },
            icon: 'path://M512 0c282.752 0 512 229.248 512 512s-229.248 512-512 512S0 794.752 0 512 229.248 0 512 0z m0 85.333333C276.352 85.333333 85.333333 276.352 85.333333 512s191.018667 426.666667 426.666667 426.666667 426.666667-191.018667 426.666667-426.666667S747.648 85.333333 512 85.333333z m0 213.333334a213.333333 213.333333 0 1 1 0 426.666666 213.333333 213.333333 0 0 1 0-426.666666z'
        },
        color: ["#2478b6", "#c2572d", "#66CCCC"],
        series: [
            {
                type: 'gauge',
                splitNumber: 8,
                center: ['50%', '50%'],
                radius: '80%',
                startAngle: 210,
                endAngle: -30,
                axisLine: {
                    show: false
                },
                axisTick: {
                    show: true,
                    lineStyle: {
                        width: 1.5,
                        color: '#4a5571',
                    },
                    length: 10,
                    splitNumber: 3
                },
                splitLine: {
                    lineStyle: {
                        opacity: 0
                    }
                },
                axisLabel: {
                    show: false
                },
                detail: {
                    show: false
                },
                pointer: {
                    show: false
                }
            },
            {
                type: 'gauge',
                center: ['50%', '50%'],
                data: [value],
                radius: '105%',
                startAngle: 210,
                endAngle: -30,
                min: 0,
                max: 160,
                splitNumber: 8,
                axisLine: {
                    show: false
                },
                axisTick: {
                    show: false
                },
                splitLine: {
                    show: false
                },
                axisLabel: {
                    distance: 0,
                    color: '#fff',
                    borderWidth: 2,
                    borderColor: '#4a5571',
                    borderRadius: 20,
                    backgroundColor: '#000',
                    width: 100,
                    padding: [3, 7, 0, 7],
    
                },
                itemStyle: {
                    show: false
                },
                detail: {
                    show: false
                },
                pointer: {
                    width: 5,
                    length: '60%',
                },
                itemStyle:{
                    color:'#164d88'
                }
            },
            {
                name: '',
                type: 'custom',
                coordinateSystem: "none",
                data: [0],
                renderItem:function(params,api) {
                    return {
                        type:'circle',
                        shape:{
                           cx:api.getWidth()/2,
                           cy:api.getHeight()/2,
                           r:Math.max(api.getWidth(),api.getHeight()) / 2 * 0.25,
                        },
                        style:{
                            stroke:'#164d88',
                            lineWidth:2,
                            fill:new echarts.graphic.RadialGradient(0.5,0.5,1,[
                                {
                                    offset:0,
                                    color:'#1a2127'
                                },
                                {
                                    offset:1,
                                    color:'#000'
                                }
                            ])
                        },
                    }
                }
            },
            {
                name: '',
                type: 'custom',
                coordinateSystem: "none",
                data: [0],
                renderItem:function(params,api) {
                    return {
                        type:'circle',
                       
                    }
                }
            }
    
        ]
    }
    return option;
}
export default opt;
export function handlerOptions(chart, newConfig) {
    if (newConfig && (Object.keys(newConfig).length !== 0)) {
        chart.setOption({ ...newConfig }, false);
        console.log(chart.getOption());
    }
}